<?php
/**
 * Build Network Administration Menu.
 *
 * @package GeChiUI
 * @subpackage Multisite
 *
 */

/* translators: Network menu item. */
$menu[2] = array( __( '仪表盘' ), 'manage_network', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'dashicons-dashboard' );

$submenu['index.php'][0] = array( __( '首页' ), 'read', 'index.php' );

if ( current_user_can( 'update_core' ) ) {
	$cap = 'update_core';
} elseif ( current_user_can( 'update_plugins' ) ) {
	$cap = 'update_plugins';
} elseif ( current_user_can( 'update_themes' ) ) {
	$cap = 'update_themes';
} else {
	$cap = 'update_languages';
}

$update_data = gc_get_update_data();
if ( $update_data['counts']['total'] ) {
	$submenu['index.php'][10] = array(
		sprintf(
			/* translators: %s: Number of available updates. */
			__( '更新%s' ),
			sprintf(
				'<span class="avatar avatar-text bg-danger avatar-xs m-l-5 count-%s"><span class="update-count">%s</span></span>',
				$update_data['counts']['total'],
				number_format_i18n( $update_data['counts']['total'] )
			)
		),
		$cap,
		'update-core.php',
	);
} else {
	$submenu['index.php'][10] = array( __( '更新' ), $cap, 'update-core.php' );
}

unset( $cap );

$submenu['index.php'][15] = array( __( '升级SaaS平台' ), 'upgrade_network', 'upgrade.php' );

$menu[4] = array( '', 'read', 'separator1', '', 'gc-menu-separator' );

/* translators: Sites menu item. */
$menu[5]                  = array( __( '多系统' ), 'manage_sites', 'sites.php', '', 'menu-top menu-icon-site', 'menu-site', 'dashicons-admin-multisite' );
$submenu['sites.php'][5]  = array( __( '所有系统' ), 'manage_sites', 'sites.php' );
$submenu['sites.php'][10] = array( _x( '添加新系统', 'site' ), 'create_sites', 'site-new.php' );

$menu[10]                 = array( __( '用户' ), 'manage_network_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'dashicons-admin-users' );
$submenu['users.php'][5]  = array( __( '所有用户' ), 'manage_network_users', 'users.php' );
$submenu['users.php'][10] = array( _x( '添加用户', 'user' ), 'create_users', 'user-new.php' );

if ( current_user_can( 'update_themes' ) && $update_data['counts']['themes'] ) {
	$menu[15] = array(
		sprintf(
			/* translators: %s: Number of available theme updates. */
			__( '主题%s' ),
			sprintf(
				'<span class="update-plugins count-%s"><span class="theme-count">%s</span></span>',
				$update_data['counts']['themes'],
				number_format_i18n( $update_data['counts']['themes'] )
			)
		),
		'manage_network_themes',
		'themes.php',
		'',
		'menu-top menu-icon-appearance',
		'menu-appearance',
		'dashicons-admin-appearance',
	);
} else {
	$menu[15] = array( __( '主题' ), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' );
}
$submenu['themes.php'][5]  = array( __( '已安装的主题' ), 'manage_network_themes', 'themes.php' );
$submenu['themes.php'][10] = array( _x( '安装主题', 'theme' ), 'install_themes', 'theme-install.php' );
$submenu['themes.php'][15] = array( __( '主题文件编辑器' ), 'edit_themes', 'theme-editor.php' );

if ( current_user_can( 'update_plugins' ) && $update_data['counts']['plugins'] ) {
	$menu[20] = array(
		sprintf(
			/* translators: %s: Number of available plugin updates. */
			__( '插件%s' ),
			sprintf(
				'<span class="update-plugins count-%s"><span class="plugin-count">%s</span></span>',
				$update_data['counts']['plugins'],
				number_format_i18n( $update_data['counts']['plugins'] )
			)
		),
		'manage_network_plugins',
		'plugins.php',
		'',
		'menu-top menu-icon-plugins',
		'menu-plugins',
		'dashicons-admin-plugins',
	);
} else {
	$menu[20] = array( __( '插件' ), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'dashicons-admin-plugins' );
}
$submenu['plugins.php'][5]  = array( __( '已安装的插件' ), 'manage_network_plugins', 'plugins.php' );
$submenu['plugins.php'][10] = array( _x( '安装插件', 'plugin' ), 'install_plugins', 'plugin-install.php' );
$submenu['plugins.php'][15] = array( __( '插件文件编辑器' ), 'edit_plugins', 'plugin-editor.php' );

$menu[25] = array( __( '设置' ), 'manage_network_options', 'settings.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' );
if ( defined( 'MULTISITE' ) && defined( 'GC_ALLOW_MULTISITE' ) && GC_ALLOW_MULTISITE ) {
	$submenu['settings.php'][5]  = array( __( '平台设置' ), 'manage_network_options', 'settings.php' );
	$submenu['settings.php'][10] = array( __( 'SaaS平台配置' ), 'setup_network', 'setup.php' );
}
unset( $update_data );

$menu[99] = array( '', 'exist', 'separator-last', '', 'gc-menu-separator' );

require_once ABSPATH . 'gc-admin/includes/menu.php';
